#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    actionSeparator=new QAction(this);
    actionSeparator->setSeparator(true);
    updateMenus();
    connect(ui->mdiArea,SIGNAL(subWindowActivated(QMdiSubWindow*)),SLOT(updateMenus()));
}
void MainWindow::updateMenus()
{
    bool has=(activeMdiChild()!=0);
    ui->actionSave->setEnabled(has);
    ui->actionPaste->setEnabled(has);
    ui->actionCopy->setEnabled(has);
    ui->actionCut->setEnabled(has);
    ui->actionColse->setEnabled(has);
    ui->actionNext->setEnabled(has);
    ui->actionPrevious->setEnabled(has);
    ui->actionRedo->setEnabled(has);
    ui->actionUndo->setEnabled(has);
    actionSeparator->setVisible(has);

    bool selc=(activeMdiChild()&&activeMdiChild()->document()->isUndoAvailable);

}


MdiChild * MainWindow::activateWindow()
{
    if(QMdiSubWindow * activeSubWindow=ui->mdiArea->activeSubWindow())
        return qobject_cast<MdiChild *>(activeSubWindow->widget());
    return 0;
}

MainWindow::~MainWindow()
{
    delete ui;
}
